using System.Globalization;
using System.Xml.Serialization;

namespace HengTong.Kingdee.Connected_Services.WSExportMaterialGroupFacade
{
    /// <summary>
    /// 物料分组数据信息
    /// </summary>
    [XmlRoot("DataInfo")]
    public class MaterialGroupDataInfo
    {
        [XmlElement("DataHead")]
        public MaterialGroupDataHead DataHead { get; set; }
    }

    /// <summary>
    /// 物料分组数据头
    /// </summary>
    public class MaterialGroupDataHead
    {
        /// <summary>
        /// 创建时间（原始字符串）
        /// </summary>
        [XmlElement("createTime")]
        public string CreateTimeString { get; set; }

        /// <summary>
        /// 创建时间（DateTime 类型）
        /// </summary>
        [XmlIgnore]
        public DateTime? CreateTime
        {
            get
            {
                if (string.IsNullOrWhiteSpace(CreateTimeString))
                    return null;
                if (DateTime.TryParseExact(CreateTimeString, "yyyy-MM-dd HH:mm:ss", 
                    CultureInfo.InvariantCulture, DateTimeStyles.None, out var result))
                    return result;
                return null;
            }
        }

        /// <summary>
        /// 简称
        /// </summary>
        [XmlElement("simpleName")]
        public string SimpleName { get; set; }

        /// <summary>
        /// 删除状态
        /// </summary>
        [XmlElement("deletedStatus")]
        public int DeletedStatus { get; set; }

        /// <summary>
        /// CU
        /// </summary>
        [XmlElement("CU")]
        public int CU { get; set; }

        /// <summary>
        /// 发送消息
        /// </summary>
        [XmlElement("sendMsg")]
        public string SendMsg { get; set; }

        /// <summary>
        /// 最后更新时间（原始字符串）
        /// </summary>
        [XmlElement("lastUpdateTime")]
        public string LastUpdateTimeString { get; set; }

        /// <summary>
        /// 最后更新时间（DateTime 类型）
        /// </summary>
        [XmlIgnore]
        public DateTime? LastUpdateTime
        {
            get
            {
                if (string.IsNullOrWhiteSpace(LastUpdateTimeString))
                    return null;
                if (DateTime.TryParseExact(LastUpdateTimeString, "yyyy-MM-dd HH:mm:ss", 
                    CultureInfo.InvariantCulture, DateTimeStyles.None, out var result))
                    return result;
                return null;
            }
        }

        /// <summary>
        /// 最后更新用户
        /// </summary>
        [XmlElement("lastUpdateUser")]
        public string LastUpdateUser { get; set; }

        /// <summary>
        /// 父级
        /// </summary>
        [XmlElement("parent")]
        public string Parent { get; set; }

        /// <summary>
        /// 分组标准
        /// </summary>
        [XmlElement("groupStandard")]
        public string GroupStandard { get; set; }

        /// <summary>
        /// 编号
        /// </summary>
        [XmlElement("number")]
        public string Number { get; set; }

        /// <summary>
        /// 创建人
        /// </summary>
        [XmlElement("creator")]
        public string Creator { get; set; }

        /// <summary>
        /// 层级
        /// </summary>
        [XmlElement("level")]
        public int Level { get; set; }

        /// <summary>
        /// 描述
        /// </summary>
        [XmlElement("description")]
        public string Description { get; set; }

        /// <summary>
        /// 是否叶子节点
        /// </summary>
        [XmlElement("isLeaf")]
        public int IsLeaf { get; set; }

        /// <summary>
        /// 名称
        /// </summary>
        [XmlElement("name")]
        public string Name { get; set; }

        /// <summary>
        /// 发送次数
        /// </summary>
        [XmlElement("sendCount")]
        public int SendCount { get; set; }

        /// <summary>
        /// 是否同步
        /// </summary>
        [XmlElement("IsSynochronous")]
        public int IsSynochronous { get; set; }

        /// <summary>
        /// 是否发送
        /// </summary>
        [XmlElement("isSend")]
        public int IsSend { get; set; }

        /// <summary>
        /// 显示名称
        /// </summary>
        [XmlElement("displayName")]
        public string DisplayName { get; set; }

        /// <summary>
        /// 长编号
        /// </summary>
        [XmlElement("longNumber")]
        public string LongNumber { get; set; }
    }
}
